package com.servlet.article;

import java.io.IOException;

import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import com.dao.ArticleDAO;
import com.entity.Article;

public class FindArticleByIdServlet extends HttpServlet {

	public void doGet(HttpServletRequest request, HttpServletResponse response)
			throws ServletException, IOException {
        request.setCharacterEncoding("utf-8");
		int articleId = Integer.parseInt(request.getParameter("article_id"));//获取参数
		ArticleDAO articleDAO = new ArticleDAO();//实现数据库
		Article article = articleDAO.findById_user_name(articleId);
		request.setAttribute("article", article);

		request.getRequestDispatcher("/background/updatearticle.jsp").forward(
				request, response);
	}

	public void doPost(HttpServletRequest request, HttpServletResponse response)
			throws ServletException, IOException {
		request.setCharacterEncoding("utf-8");
		int articleId = Integer.parseInt(request.getParameter("article_id"));//获取参数
		ArticleDAO articleDAO = new ArticleDAO();
		Article article = articleDAO.findById_user_name(articleId);
		request.setAttribute("article", article);

		request.getRequestDispatcher("/background/updatearticle.jsp").forward(
				request, response);
	}
}
